import requests
from typing import Union

# 定义请求体的数据
data = {
    "name": "Test Item",
    "description": "This is a test item",
    "price": 99.99,
    "tax": 10.5
}

# 发送 POST 请求
response = requests.post("http://127.0.0.1:8002/items", json=data)

# 检查响应状态码
if response.status_code == 200:
    print("POST request successful!")
    print("Response:", response.json())
else:
    print(f"POST request failed with status code {response.status_code}")
    print("Response:", response.text)

# 发送 put 请求
res = requests.put("http://127.0.0.1:8002/items/10", json=data)
if res.status_code == 200:
    print("PUT request successful!")
    print("Response:", res.json())
else:
    print(f"POST request failed with status code {res.status_code}")
    print("Response:", res.text)

if __name__ == '__main__':
    pass
